import torch.nn

from python_sklearn.dataset import mydataset
import numpy as np
import pandas as pd
from myLinerModel import LinearModel

if __name__ == '__main__':
    x=mydataset().onehot()[0]
    print(x)
    x=torch.Tensor(x.values.tolist())

    y=mydataset().onehot()[1]
    y=torch.Tensor(np.array(y))

    model=LinearModel()
    criterion=torch.nn.MSELoss(size_average=False)
    optimizer=torch.optim.SGD(model.parameters(),lr=0.000000001)

    for epoch in range(100):
        y_pred=model(x)
        loss=criterion(y_pred,y)
        print(epoch,loss.item())
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()

